//
//  OrderDetailGoodsView.swift
//  LeGou
//
//  Created by lxm on 2022/8/5.
//

import UIKit

class OrderDetailGoodsView: ZMXIBView {

    //MARK: --------------------属性--------------------
    
    //MARK: --------------------UI控件--------------------
    @IBOutlet weak var img: UIImageView!
    
    @IBOutlet weak var name: UILabel!
    
    @IBOutlet weak var price: UILabel!
    
    @IBOutlet weak var num: UILabel!
    
    @IBOutlet weak var activityNum: UIButton!
    
    @IBOutlet weak var titleBtn: UIButton!
    
    @IBOutlet weak var unit: UILabel!
    
    let tan = DetailShareView.TriangleView()

    @IBOutlet weak var topleftIcon: UIView!
    //MARK: --------------------生命周期--------------------
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
        bindAction()
        addConstraints()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        setUI()
        bindAction()
        addConstraints()
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        activityNum.style.GradientLeftToRight(Top: "#F8D490".zm.hex(), Bottom: "#FBE7AF".zm.hex())
        
        topleftIcon.style.GradientLeftToRight(left: "#F07650".zm.hex(), right: "#DC1927".zm.hex())
        ZMUtil.clipCircle(view: topleftIcon, Corner: [.topLeft, .bottomRight], radius: 8)
    }

    //MARK: --------------------UI--------------------
    func setUI() {
        makeTan()
    }
    
    func makeTan() {
        tan.direction = .up
        tan.fillColor = UIColor.zm.color(hexString: "#F9D591", 0.65)
        addSubview(tan)
        tan.snp.makeConstraints { make in
            make.centerX.equalTo(activityNum)
            make.bottom.equalTo(activityNum.snp.top)
            make.width.equalTo(5)
            make.height.equalTo(3.5)
        }
    }
    
    func addConstraints() {
     
    }
    
    //MARK: --------------------methods--------------------
    func bindAction() {
        
    }
    
    func showActivity(_ show : Bool, value : String) {
        self.tan.isHidden = !show
        self.activityNum.isHidden = !show
        self.activityNum.setTitle("+\(value)活跃度", for: .normal)
        layoutIfNeeded()
    }
    //MARK: --------------------delegate--------------------

}
